using ShawnFramework;
using System.Collections.Generic;
using UnityEngine;

/// <summary>
/// 全局游戏启动器
/// </summary>
public class Global : MonoBehaviour
{
    public static Global Instance;
    // 游戏流程管理器
    public GameFlowManager FlowMng { get; private set; } = null;
    // 游戏面板容器
    public PanelContainer PanelContainer { get; private set; }

    private List<ILifeCycle> lifeCycles = new();

    void Awake()
    {
        Instance = this;
        DontDestroyOnLoad(gameObject);

        PanelContainer = FindObjectOfType<PanelContainer>();
        FlowMng = new GameFlowManager();
        lifeCycles.Add(FlowMng);

        foreach (ILifeCycle lifeCycle in lifeCycles)
        {
            lifeCycle.OnInit();
        }
    }
    void Update()
    {
        foreach (ILifeCycle lifeCycle in lifeCycles)
        {
            lifeCycle.OnTick();
        }
    }
    void OnDestroy()
    {
        foreach (ILifeCycle lifeCycle in lifeCycles)
        {
            lifeCycle.OnUninit();
        }
    }
}
